import cooApp, { coolink, Util, ui } from 'coolink-ts'
import baseInfo from './baseInfo'

const designWidth: number = 375;
export function px(sizeValue: number): number {
    let screenWidth: number = ui.screenWidth;
    if (screenWidth <= 375) {
        return sizeValue;
    }
    if (sizeValue == 1) {
        return 1;
    }
    return Math.floor(sizeValue * screenWidth / designWidth);
}


function getRemoteDeviceInfos(showToast: Function, content: string) {
    Util.log('getRemoteDeviceInfos');
    coolink.protocol.getDeviceList()
        .then((res) => {
            Util.log('getDeviceList', JSON.stringify(res));
            if (res.code == 0) {
                if (res.list.length > 0) {
                    if (showToast) showToast(content);
                } else {
                    coolink.nativeui.showConnectDeviceDialog();
                }
            } else {
                coolink.nativeui.showConnectDeviceDialog();
            }
        })

}


export default {
    getRemoteDeviceInfos,
}